package com.jp.knowledge.my.adapter;

import android.content.Context;
import android.support.annotation.NonNull;

import com.jp.knowledge.R;
import com.jp.knowledge.my.base.RecycleVAdapter;
import com.jp.knowledge.my.base.RecycleVHolder;
import com.jp.knowledge.my.model.OrganizaModel;

import java.util.List;

/**
 * Created by 528787067@qq.com on 2017/3/27.
 */

public class UserSettingCompanysAdapter extends RecycleVAdapter<OrganizaModel> {

    public UserSettingCompanysAdapter(Context context, @NonNull List<OrganizaModel> list) {
        super(context, list);
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_usersetting_company;
    }

    @Override
    public void onBind(RecycleVHolder holder, int position) {
        OrganizaModel organizaModel = getData(position);
        holder.setTextView(R.id.name, organizaModel.getCompanyFullName());

        String comDepartment = organizaModel.getDepartment();
        String comPosition = organizaModel.getPosition();
        if(organizaModel.getCompanyType() == 2)
            holder.setTextView(R.id.desc, "");
        else if((comDepartment == null || comDepartment.equals("") || comDepartment.equals("未知部门"))
                && (comPosition == null || comPosition.equals("") || comPosition.equals("未知职位")))
            holder.setTextView(R.id.desc, "(需补充职位和部门)");
        else if(comDepartment == null || comDepartment.equals("") || comDepartment.equals("未知部门"))
            holder.setTextView(R.id.desc, "(需补充部门)");
        else if(comPosition == null || comPosition.equals("") || comPosition.equals("未知职位"))
            holder.setTextView(R.id.desc, "(需补充职位)");
        else
            holder.setTextView(R.id.desc, "");
    }
}
